package com.shop.domain.pink;

import java.util.Date;
import java.math.BigDecimal;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.*;
import javax.persistence.Table;
import com.alibaba.fastjson.annotation.JSONField;
import com.shop.jpa.domain.BaseDomain;
import com.shop.jpa.support.JpaConst;
import com.shop.util.IdSignUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

/**
 * <p>StorePink 实体类</p>
 * <p>Table: t_store_pink - 拼团表</p>
 * @author generator
 * @date 2021-02-19 06:39:51
 */
@ApiModel("StorePink 实体类")
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "t_store_pink")
@SQLDelete(sql = "update t_store_pink set is_deleted = 1 where id = ?")
@Where(clause = JpaConst.WHERE_CLAUSE_NOT_DELETED)
@DynamicInsert(true)
@DynamicUpdate(true)
public class StorePink extends BaseDomain implements Serializable {

    @ApiModelProperty(value = "id", hidden = true)
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
	@JSONField(serialize=false)
    private Long id;

    /**
	 * 用户id
	 */
    @ApiModelProperty("用户id")
	@Column(name = "uid")
    private Long uid;

    /**
	 * 拼团id
	 */
    @ApiModelProperty("拼团id")
	@Column(name = "pink_id")
    private Long pinkId;

    /**
	 * 订单id 生成
	 */
    @ApiModelProperty("订单id 生成")
	@Column(name = "order_no")
    private String orderNo;

    /**
	 * 购买总金额
	 */
    @ApiModelProperty("购买总金额")
	@Column(name = "total_price")
    private BigDecimal totalPrice;

    /**
	 * 商品id
	 */
    @ApiModelProperty("商品id")
	@Column(name = "product_id")
    @JSONField(serialize=false)
    private Long productId;

    /**
	 * 产品规格id
	 */
    @ApiModelProperty("产品规格id")
	@Column(name = "product_attr_value_id")
    @JSONField(serialize=false)
    private Long productAttrValueId;

    /**
	 * 拼团商品单价
	 */
    @ApiModelProperty("拼团商品单价")
	@Column(name = "price")
    private BigDecimal price;

    /**
     * 地址id
     */
    @ApiModelProperty("地址id")
    @Column(name = "user_address_id")
    @JSONField(serialize = false)
    private Long userAddressId;

    /**
	 * 状态1进行中2已完成3已中奖4取消
	 */
    @ApiModelProperty("状态0 未支付 1进行中（已支付）,2已中奖,3寄售，4提货，5取消")
	@Column(name = "status")
    private int status;

    /**
	 * 拼团次数
	 */
    @ApiModelProperty("拼团次数")
	@Column(name = "pink_num")
    private Integer pinkNum;

    /**
	 * 总返利金额
	 */
    @ApiModelProperty("总返利金额")
	@Column(name = "total_amount")
    private BigDecimal totalAmount;

    /**
	 * 返佣状态0默认1可以返佣2返佣完成
	 */
    @ApiModelProperty("返佣状态0默认1可以返佣2返佣完成")
	@Column(name = "rebate_status")
    private Integer rebateStatus;

    /**
	 * 是否单论最后一单中奖（是否第五单）
	 */
    @ApiModelProperty("是否单论最后一单中奖（是否第五单）")
	@Column(name = "is_last_prize")
    private Integer isLastPrize;

    /**
	 * 中奖时间
	 */
    @ApiModelProperty("中奖时间")
	@Column(name = "zj_time")
    private Date zjTime;

    /**
     * 第几轮拼团订单
     */
    @ApiModelProperty("第几轮拼团订单")
    @Column(name = "store_pink_num")
    private Integer storePinkNum;

    /**
     * 支付类型
     */
    @ApiModelProperty("支付类型")
    @Column(name = "pay_type")
    private String payType;

    /**
     * 支付类型编码 2 微信-JT 3 支付宝-JT 12 微信-Sand 13 支付宝-Sand 8 余额 9 TG
     */
    @Column(name = "pay_code")
    @ApiModelProperty("支付类型编码 2 微信-JT 3 支付宝-JT 12 微信-Sand 13 支付宝-Sand 8 余额 9 TG")
    private Integer payCode;

    /**
     * 支付时间
     */
    @ApiModelProperty("支付时间")
    @Column(name = "pay_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date payTime;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @Column(name = "create_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 修改时间
     */
    @ApiModelProperty("修改时间")
    @Column(name = "update_time")
    @JSONField(serialize=false)
    private Date updateTime;

    /**
	 * 是否删除 0 未删除 1已删除
	 */
    @ApiModelProperty("是否删除 0 未删除 1已删除")
	@Column(name = "is_deleted")
    @JSONField(serialize=false)
    private Integer isDeleted;

    @ApiModelProperty("收货地址ID")
    @Transient
    private String userAddressSign;
    public String getUserAddressSign() {
        return IdSignUtil.doSign(this.userAddressId);
    }

    @ApiModelProperty("产品id")
    @Transient
    private String productSign;
    public String getProductSign() {
        return IdSignUtil.doSign(this.productId);
    }

    @ApiModelProperty("产品规格id")
    @Transient
    private String productAttrValueSign;
    public String getProductAttrValueSign() {
        return IdSignUtil.doSign(this.productAttrValueId);
    }
}